<?php

namespace App\Model;


use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class RoomDynamic extends BaseModel
{
    protected  $table = 'room_dynamic';

    public function getList(Request $request)
    {
        $page = $request->get('page', 1);
        $limit = $request->get('limit', 10);
        $dynamic_id = $request->input('dynamic_id');
        $query = new RoomDynamic();
        if ($dynamic_id) $query = $query->where('dynamic_id', $dynamic_id);
        $data = $query->orderBy('created_at','DESC')->paginate($limit,['*'], 'page', $page);
        foreach ($data->items() as $key => $value){
            $data->items()[$key]->img = build_image($value->img);
        }
        return $data;
    }

    public function setDynamic($data){
        curl_request(getKkaudioApiUrl()."/inner/room/dynamic/addorupdate", $data, 'json');
    }

    public function delDynamic($data){
        curl_request(getKkaudioApiUrl()."/inner/room/dynamic/del", $data, 'json');
    }
}

